import * as serviceApi from '@/services/system';


export default {
  namespace: 'system',
  state: {

    backupList: [],
  },

  effects: {
    *getBackupList({ _, callback }, { call, put }) {
      const res = yield call(serviceApi.getBackupList);
      if (callback) callback(res);
      yield put({
        type: 'save',
        payload: res,
      });
    },
    *backupDatabase({ payload, callback }, { call, put }) {
      const res = yield call(serviceApi.backupDatabase, payload);
      yield put({
        type: 'getBackupList',
      });
      if (callback) callback(res);
    },

  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        backupList: action.payload,
      };
    },
  },
};
